/**
 * 
 */
package org.compiere.model;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Properties;
import java.util.logging.Level;

import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;

/**
 * @author Arman Yerzhanov
 * Jan 31, 2013
 */
public class Mhrmpaymentline extends X_hrm_paymentline {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5901403495956704077L;
	
	/**	Static Logger	*/
	private static CLogger	s_log	= CLogger.getCLogger (Mhrmpaymentline.class);

	/**
	 * @param ctx
	 */
	public Mhrmpaymentline(Properties ctx) {
		super(ctx);
		
	}

	/**
	 * @param ctx
	 * @param hrm_paymentline_ID
	 * @param trxName
	 */
	public Mhrmpaymentline(Properties ctx, int hrm_paymentline_ID,
			String trxName) {
		super(ctx, hrm_paymentline_ID, trxName);
		
	}
	
	/**
	 * @param ctx
	 * @param rs
	 * @param trxName
	 */
	public Mhrmpaymentline(Properties ctx, ResultSet rs, String trxName) {
		super(ctx, rs, trxName);
		
	}
	
	public static Mhrmpaymentline getline(int hrm_payment_id, int C_BPartner_ID, int C_Charge_ID){
		
		if (hrm_payment_id==0)
			return null;

		//
	    PreparedStatement pstmt = null;
		ResultSet rs = null;
		Mhrmpaymentline result = new Mhrmpaymentline(Env.getCtx(), 0, null);
			
		// 
		String sql_ = "SELECT * FROM HRM_PAYMENTLINE \n " +
						"WHERE ISACTIVE='Y' \n " +
//							"AND AD_CLIENT_ID=" + Env.getAD_Client_ID(Env.getCtx()) + " \n " +
							"AND C_CHARGE_ID=" + C_Charge_ID + " \n " +
							"AND hrm_payment_id=" + hrm_payment_id + " \n " +
							"AND C_BPartner_ID =" + C_BPartner_ID ;
			try
			{
				pstmt = DB.prepareStatement(sql_,null);
				rs = pstmt.executeQuery();	
				if(rs.next())
					result = new Mhrmpaymentline(Env.getCtx(), rs, null);
			}
			catch (SQLException e)
			{
				s_log.log(Level.SEVERE, "product", e);
			}
			finally
			{
				DB.close(rs, pstmt);
				rs = null; pstmt = null;
			}	
		return result;		
	}
}
